//
//  HREnterTextFiledView.m
//  Hear
//
//  Created by mac on 2017/3/28.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HREnterTextFiledView.h"
@interface HREnterTextFiledView ()<UITextFieldDelegate>
@end
@implementation HREnterTextFiledView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.textField = [UITextField new];
        [self addSubview:self.textField];
        self.textField.textColor = [UIColor whiteColor];
        self.textField.font = CustomUIFont(15);
        self.textField.delegate = self;
        UIImageView *line = [UIImageView new];
        line.image = [UIImage imageNamed:@"分隔线"];
        [self addSubview:(self.line = line)];
        
        self.leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
        self.textField.leftView = self.leftImageView;
        self.textField.leftViewMode = UITextFieldViewModeAlways;
        
        WeakSelf
        [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.equalTo(weakSelf);
            make.height.mas_equalTo(40);
        }];
        
//        [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.top.equalTo(weakSelf.textField);
//            make.size.mas_equalTo(CGSizeMake(35, 35));
//        }];
        
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.left.equalTo(weakSelf);
            make.top.equalTo(self.textField.mas_bottom);
            make.height.mas_equalTo(1);
        }];
        
    }
    return self;
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

@end
